# import math
# for i in range(10000):
#     x = int(math.sqrt(i+100))
#     y = int(math.sqrt(i+268))
#     if (x*x)==(i+100) and (y*y)==(i+268):
#         print(i)

year = int(input("请输入年（例2001）："))
month = int(input("请输入1~12月："))
day = int(input("请输入1~31日"))

months = (0,31,59,90,120,151,181,212,243,273,304,334)

if 1<=month<=12:
    sum = months[month-1]
else:
    print("输入错误")

b = sum + day

if ((year % 400 == 0) or ((year % 4 == 0) and (year % 100 != 0)) and (month>2)):
    a= b + 1
    print(a)
else:
    print(b)
